/**
 * Copyright (c) 2018 软唐 All rights reserved.
 *
 * https://www.softtown.cn
 *
 * 版权所有，侵权必究！
 */

package com.softtown.modules.dapai.controller;

import com.github.pagehelper.PageInfo;
import com.softtown.common.utils.Result;
import com.softtown.modules.dapai.dto.CompWarehouseDTO;
import com.softtown.modules.dapai.entity.CompWarehouseEntity;
import com.softtown.modules.dapai.service.CompWarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* @Author: Ding Ya Yong
* @Description: 仓库信息
* @date: 2022/1/2 20:47
* @Param:
* @return:
*/
@RestController
@RequestMapping("warehouse")
@Api(tags="仓库信息")
public class CompWarehouseController {

    @Resource
    private CompWarehouseService compWarehouseService;

    @PostMapping("getWarehousePageList")
    @ApiOperation("获取仓库信息分页")
    public Result getWarehousePageList(@RequestBody CompWarehouseDTO compWarehouseDTO) {
        PageInfo<CompWarehouseDTO> compWarehouseDTOPageInfo = compWarehouseService.getWarehousePageList(compWarehouseDTO);
        return new Result<PageInfo<CompWarehouseDTO>>().ok(compWarehouseDTOPageInfo);
    }



    @PostMapping("getWarehouseById")
    @ApiOperation("获取仓库信息详情")
    public Result<CompWarehouseEntity> getWarehouseById(@RequestBody CompWarehouseDTO compWarehouseDTO) {
        CompWarehouseEntity compWarehouseEntity = compWarehouseService.getWarehouseById(compWarehouseDTO.getCompId(),compWarehouseDTO.getId());
        return new Result<CompWarehouseEntity>().ok(compWarehouseEntity);
    }


    @PostMapping("addWarehouse")
    @ApiOperation("添加仓库信息")
    public Result addWarehouse(@RequestBody CompWarehouseDTO compWarehouseDTO) {
        Result result = new Result<>();
        compWarehouseService.addWarehouse(compWarehouseDTO);
        return result;
    }

    @PostMapping("updateWarehouse")
    @ApiOperation("修改仓库信息")
    public Result updateWarehouse(@RequestBody CompWarehouseDTO compWarehouseDTO) {
        Result result = new Result<>();
        compWarehouseService.updateWarehouse(compWarehouseDTO);
        return result;
    }

    @PostMapping("deleteWarehouse")
    @ApiOperation("删除仓库信息")
    public Result deleteWarehouse(@RequestBody CompWarehouseDTO compWarehouseDTO) {
        Result result = new Result<>();
        compWarehouseService.deleteWarehouse(compWarehouseDTO);
        return result;
    }

}
